package com.restaurant.application.indexes.couponmanagelist.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;
import java.lang.Integer;
import java.lang.String;
import java.util.List;

public class QueryData implements PickableBean {
    
    public static final String FN_ID = "id";
    public static final String FN_NAME = "name";
    public static final String FN_STATE = "state";
    public static final String FN_TYPE = "type";
    public static final String FN_PAGE = "page";
    
    public static final List<String> FIELD_NAMES = Lists.newArrayList(
             FN_ID,
             FN_NAME,
             FN_STATE,
             FN_TYPE,
             FN_PAGE);
    
    private String id;
    private String name;
    private String state;
    private String type;
    private Integer page;
    
    public QueryData(String id, String name, String state, String type, Integer page) {
        setId(id);
        setName(name);
        setState(state);
        setType(type);
        setPage(page);
    }
    
    public QueryData() {
    }
    
    public QueryData duplicate() {
        QueryData result = new QueryData();
        result.id = this.id;
        result.name = this.name;
        result.state = this.state;
        result.type = this.type;
        result.page = this.page;
        return result;
    }
    
    @Override
    public String toString() {
        return Convert.toJson(this);
    }
    
    public String getId() {
        return id;
    }
    
    public void  setId(String value) {
        this.id = value;
    }
    
    public QueryData withId(String value) {
        setId(value);
        return this;
    }
    
    public QueryData withId(String value, String defaultValue) {
        setId(value == null ? defaultValue : value);
        return this;
    }
    
    public String getName() {
        return name;
    }
    
    public void  setName(String value) {
        this.name = value;
    }
    
    public QueryData withName(String value) {
        setName(value);
        return this;
    }
    
    public QueryData withName(String value, String defaultValue) {
        setName(value == null ? defaultValue : value);
        return this;
    }
    
    public String getState() {
        return state;
    }
    
    public void  setState(String value) {
        this.state = value;
    }
    
    public QueryData withState(String value) {
        setState(value);
        return this;
    }
    
    public QueryData withState(String value, String defaultValue) {
        setState(value == null ? defaultValue : value);
        return this;
    }
    
    public String getType() {
        return type;
    }
    
    public void  setType(String value) {
        this.type = value;
    }
    
    public QueryData withType(String value) {
        setType(value);
        return this;
    }
    
    public QueryData withType(String value, String defaultValue) {
        setType(value == null ? defaultValue : value);
        return this;
    }
    
    public Integer getPage() {
        return page;
    }
    
    public void  setPage(Integer value) {
        this.page = value;
    }
    
    public QueryData withPage(Integer value) {
        setPage(value);
        return this;
    }
    
    public QueryData withPage(Integer value, Integer defaultValue) {
        setPage(value == null ? defaultValue : value);
        return this;
    }
    
    public Object getValueOf(String name) {
        switch(name) {
        case "id": return getId();
        case "name": return getName();
        case "state": return getState();
        case "type": return getType();
        case "page": return getPage();
        }
        return null;
    }
    
    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }
    
    @Override
    public int hashCode() {
        return signature().hashCode();
    }
    
    @Override
    public boolean equals(Object o) {
        if(!(o instanceof QueryData)) return false;
        return signature().equals(((QueryData)o).signature());
    }
    
    public String signature() {
        throw new RuntimeException("Bean QueryData has no signature defined, no hash code or equals possible.");
    }
}
